<?php
/**
 * +--------------------------------------------------------------
 * | eLuoPHP
 * +--------------------------------------------------------------
 * | Copyright (c) 2013-2019 http://qxwoo.cn All rights reserved.
 * +--------------------------------------------------------------
 * | y139w <y139w@163.com>
 * +--------------------------------------------------------------
 * | 2019/08/02 23:54:39
 * +--------------------------------------------------------------
 * | Content.php
 * +--------------------------------------------------------------
 */


namespace luo\traits;


trait Content
{

    public static function text($content, $length = false){

        $regex = '/<[^>]+>/s';
        $content = htmlspecialchars_decode($content);
        $content = preg_replace($regex, '', $content);
        if($length){
            $content = mb_substr($content, 0, $length, 'utf-8');
        }
        return $content;

    }

}